/**
 * 
 */
package RecordManagement;

import java.io.IOException;

/**
 * @author Neil
 * HOW TO USE PM_Manager
 * This is a record management component.
 * There should be only one RM_Manager in a db system.
 * For lower layer, it reads pages and manipulate it.
 * For upper layer, it offers a view of a list of unordered record.
 * Following must be noticed that:
 * 1. Each file store records of the same size.
 * 2. Typically, to add a record into a paged file, one may do the followings:
 *    1> Create/Open a file, the manager will handle with the initialization.
 *    2> The RM_Manager will return a RM_FileHandle for later use.
 *    3> The RM_FileHandle offer a method for inserting a record.
 *    4> The InsertRec method will return a RID telling the record position in the file.
 *    5> One may use the RID to get the record data by calling GetRec method.
 *    6> GetRec method will return a RM_Record containing the data and information.
 *    7> Meanwhile, one may not get the RID by InsertRec. 
 *       Instead, one may use RM_FileScan.
 *       Detailed use of RM_FileScan see RM_FileScan_Interface.
 */
public interface RM_Manager_Interface {
	
	/* Since each file will have its own fixed record size,
	 * a recordSize should be determined when a file is created.
	 * If recordSize is larger than the pageSize, a PF_Abort_Exception will be thrown.
	 * This method will initialize the RM_FileHead in the memory and file.
	 * */
	RM_FileHandle CreateFile (String filename, int recordSize) throws IOException;
	
	/* Destorying a file is an unusual thing.
	 * Only when a table is to be disposed, this method is called.
	 */
	void DestoryFile (String filename);
	
	/* If a table has been established,
	 * using OpenFile will tell the manager to open the file and load meta-data.
	 */
	RM_FileHandle OpenFile(String filename) throws IOException;
	
	/* When a table is not to be used, a CloseFile may be called.
	 * This method will cause all the related buffer flushed.
	 */
	void CloseFile(RM_FileHandle fh);
}
